<template>
	<view class="login">
		<button type="primary" open-type="getPhoneNumber" class="login_button" @getphonenumber="login">登录</button>
	</view>
</template>

<script>
export default {
	data () {
		return {}
	},
	methods: {
		login (e) {
			var detail = e.detail
			var that = this
			if (detail.errMsg == "getPhoneNumber:ok") {
				that.$request('mobile/wxXcxUserPhoneNumber', 'post', {code: detail.code}).then(res => {
					console.log('res',res)
					if (res.data.userinfo && res.data.userinfo.phone_info) {
						uni.setStorageSync('mobile', res.data.userinfo.phone_info.phoneNumber)
						uni.redirectTo({
						    url: '/pages/index/index'
						});
					}
				})
			}

		}
	}
}
</script>
	
<style lang="scss">
	.login {
		width: 100%;
		height: 100vh;
		display: flex;
		justify-content: center;
		align-items: center;
		button {
			width: 80%;
			background: #409eff;
		}
	}
</style>